package com.itboye.sunsun.person.ui;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;

import com.itboye.sunsunhome.R;
import com.itboye.sunsun.support.BaseActivity;

public class ProtocalActivity extends BaseActivity implements OnClickListener {

	private ImageView back;
	private WebView webview;
	String url = "http://sunsun.8raw.com/Public/html/newcopyright.html";

	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setContentView(R.layout.activity_protocal);
		setStatusBarColor(R.color.home_blue);
		webviewsettings();
	}

	public void webviewsettings() {

		webview.getSettings().setJavaScriptEnabled(true);
		webview.loadUrl(url);
		// webview.postUrl(url, postData);
		webview.setWebViewClient(new WebViewClient()

		{

			@Override
			public void onReceivedError(WebView view, int errorCode,
					String description, String failingUrl) {
				// TODO Auto-generated method stub
				// super.onReceivedError(view, errorCode, description,
				// failingUrl);
				view.loadUrl("file:///android_asset/nonet.html");
			}

		});
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.back:
			this.finish();
			break;

		default:
			break;
		}

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if (webview.canGoBack()) {
				webview.goBack();
				return true;
			}

		}
		return super.onKeyDown(keyCode, event);
	}

}
